package com.sam.im.heiqun.uis.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.sam.im.heiqun.R;
import com.sam.im.heiqun.app.App;
import com.sam.im.heiqun.utils.ToolsUtils;
import com.yuyh.library.uis.activitys.BaseSwipeBackActivity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by wangguodong on 2017/9/6.
 */

public class SetTwoActivity extends BaseSwipeBackActivity {

    @BindView(R.id.linear_msg_tip)
    LinearLayout linear_msg_tip;
    @BindView(R.id.linear_account_security)
    LinearLayout linear_account_security;
    @BindView(R.id.linear_privacy_set)
    LinearLayout linear_privacy_set;
    @BindView(R.id.linear_about_us)
    LinearLayout linear_about_us;
    @BindView(R.id.linear_help_feedback)
    LinearLayout linear_help_feedback;
    @BindView(R.id.linear_laboratory)
    LinearLayout linear_laboratory;
    @BindView(R.id.linear_exit)
    LinearLayout linear_exit;
    @BindView(R.id.linear_more_lan)
    LinearLayout linear_more_lan;

    @Override
    protected String getTitleText() {
        return getResources().getString(R.string.system_set);
    }

    @Override
    protected void initViews(Bundle savedInstanceState) {

    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_set_two;
    }

    @OnClick({R.id.linear_msg_tip, R.id.linear_account_security, R.id.linear_privacy_set, R.id.linear_about_us, R.id.linear_help_feedback,
        R.id.linear_laboratory, R.id.linear_exit, R.id.linear_more_lan})
    public void onClick(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.linear_exit:
                doExit();
                break;
            case R.id.pre_v_back:
                scrollToFinishActivity();
                break;
            case R.id.linear_msg_tip:
                MessageTipSetActivity.start(SetTwoActivity.this);
                break;
            case R.id.linear_account_security:
                AcountSecurityActivity.start(SetTwoActivity.this);
                break;
            case R.id.linear_privacy_set:
                startActivity(PrivacyActivity.class);
                break;
            case R.id.linear_about_us:
                startActivity(AboutUsActivity.class);
                break;
            case R.id.linear_help_feedback :
//                showToast("敬请期待！");
                MyWebViewManageActivity.start(SetTwoActivity.this, 1, "http://samim.huiwork.com/feedback");
                break;
            case R.id.linear_laboratory :
//                showToast("敬请期待！");
                LaboratoryActivity.start(SetTwoActivity.this);
                break;
            case R.id.linear_more_lan :
//
                MoreLanguageSetActivity.start(SetTwoActivity.this);
                break;
        }
    }

    /**
     * 做 退出登录 操作
     */
    public void doExit() {
        //App.userEntivity.delete();//从数据库中删除登录信息
        //App.userEntivity = null;//清除之前登陆的数据
        App.isManualLogout = true;
        Intent intent = new Intent(this, LoginActivity.class);
        ToolsUtils.saveLoginstate(this,false,1);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        //  stopService(new Intent(PrivacyActivity.this,AcceptService.class));
        //先断掉连接，然后关闭socket
        if (App.getInstance().getSocket() != null) {
            App.getInstance().getSocket().disconnect();
            App.getInstance().getSocket().close();
            App.socket=null;
        }
        startActivity(intent);
        finish();


    }

}
